var invalidImgUrl;


$(document).ready(function(){
	initializeValidation();
	
	$.ajaxSetup({
		    	url: AJAX_URL,
				dataType: "JSON",
				type: "POST",
	});

});

function initializeValidation()
{
	jQuery.validator.setDefaults({
                
                errorPlacement: function(error, element) {
                	error.insertAfter(element);
                },
                 highlight: function(element, errorClass, validClass) {
                    $(element).addClass(errorClass).removeClass(validClass);
                    
                },
                unhighlight: function(element, errorClass, validClass) {
                    $(element).removeClass(errorClass).addClass(validClass);
                    
                },

               showErrors: function(errorMap, errorList) {
                    $.each(errorList, function() {
                        var message = this.message;
                        var img = new Image();
                        img.src = invalidImgUrl;
                        img.alt = "invalid";
                        $(img).attr("bt-xTitle","Error");
                        $(img).addClass("invalidImage");
                        $(img).bt(message, 
                        	{ 
                        		  //fill: 'yellow',
   								  strokeStyle: 'red',
                                  cssClass: "tooltipInvalidCssClass",
                                  positions: ["right"]
                             });
                        this.message = img;
                    });
                    this.defaultShowErrors();
                }
            });
}
